Prev Next |
Method Renderings are .NET methods which accept no parameter and return a string which are registered as Renderings with Sitecore.
First create the class containing the method in Microsoft® Visual Studio .NET. Ensure the assembly (DLL) containing the new class exists in the /bin directory under the Sitecore site’s document root.
Currently Method Renderings cannot be added to a Layout or Sublayout using drag-and-drop. If the Method Rendering will only be bound to a Layout or Sublayout statically, simply edit the Layout or Sublayout which will contain the Method Rendering and add a line such as the following:
(replacing methodname, classname and assemblyname with appropriate values).
To bind the Method Rendering to a Placeholder in a Layout or Sublayout, the Method must be registered in Sitecore as a Rendering:
Unfortunately this wizards has not been completed:
- In content editor, change the first step of the treecrumb to Layout.
- Expand the Renderings node and select an existing Rendering.
- From the New menu select Add from Template.
- Select System, Layout, Renderings and Method Rendering.
- Move the new Rendering from under the existing Rendering to the main Renderings so that it is not a child of another Rendering.
- Complete the properties of the new Rendering (additional details are available at http://sdn.sitecore.net/Articles/4,-d-,3/Method%20Renderings.html):
- Assembly: the name of the assembly containing the class containing the method (the file name of the DLL without the .dll extension)
- Class: the fully qualified class containing the method (namespace.classname)
- Method: the name of the method to be invoked when the Rendering is processed
- Associate the new Rendering with a Placeholder key for Templates and/or Items just as you would do with a Sublayout or XSL Rendering.
As a shortcut for registering additional Method Renderings, duplicate an existing Method Rendering and change its properties (starting at step 6 above).
Prev Next